package com.sumainfor.schedule.controller;

import com.sumainfor.schedule.service.impl.ActivityService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * 功能描述:
 *
 * @Auther: zhlu
 * @Date: 2019/2/25 19:50
 * @Description:
 */
@Component
public class ActivityController {

    Logger log= LoggerFactory.getLogger(ActivityController.class);

    @Autowired
    ActivityService ActivityService;

    /**
     * 功能描述: 
     * 活动超时修改状态为已过期
     * 一个小时执行一次
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/2/25 19:52
     */
    @Scheduled(cron = "0 0 */1 * * ?")
    public void ActTimeOut(){
//        log.info("输出-------");
        Map<String,Object> params=new HashMap<String,Object>();
        params.put("delfg","0");
        ActivityService.getActivityList(params);
    }

    /**
     * 功能描述: 
     * 获取所有有效活动,计算出最优活动
     * 每天晚上凌晨1点
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/2/26 18:08
     */
//    @Scheduled(cron = "0/59 * * * * ? ")
    @Scheduled(cron = "0 0 1 * * ?")
    public void OptimalActivity(){
        Map<String,Object> params=new HashMap<String,Object>();
        params.put("delfg","0");
        params.put("Status","0");
        ActivityService.getActivityHousingList(params);
    }
}
